<extend name="./public/frame.html"/>
<block name="content">
    <table class="layui-table" lay-data="{height:'auto', url:'{:url('driver/tableMoney')}', page: true, limit: '10', id:'driver'}"
           lay-filter="driver">
        <thead>
        <tr>
            <th lay-data="{checkbox:true, fixed: true}"></th>
            <th lay-data="{field:'driver_id', width:80, fixed: true, sort: true}">ID</th>
            <th lay-data="{field:'driver_name', width:120,}">司机姓名</th>
            <th lay-data="{field:'money', width:120, sort: true,templet:'#moneyTpl'}">余额</th>
            <th lay-data="{toolbar: '#barDemo',width:245,fixed:'right',align:'center'}">操作</th>
        </tr>
        </thead>
    </table>
    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-xs" lay-event="money">提现记录</a>
        <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="flow">资金记录</a>
        <!--<a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="bank">银行卡信息</a>-->
    </script>
    <script type="text/html" id="moneyTpl">
        <span>{{(d.money/100).toFixed(2)}}元</span>
    </script>
    <script>
        layui.use('table', function () {
            var table = layui.table;
            table.on('tool(driver)', function (obj) {
                var data = obj.data; //获得当前行数据
                var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
                var driver_id = data.driver_id;
                if (layEvent === 'money') {
                    layer.open({
                        type: 2,
                        title: data.driver_name+'的提现记录',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['100%', '100%'],
                        content: '{:url("/admin/cash/index","driver_id=")}' + driver_id //iframe的url
                    });
                }
                else if (layEvent === 'flow') {
                    layer.open({
                        type: 2,
                        title: data.driver_name+'的资金记录',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['100%', '100%'],
                        content: '{:url("/admin/cash/flow","driver_id=")}' + driver_id //iframe的url
                    });
                }
                else if (layEvent === 'bank') {
                    layer.open({
                        type: 2,
                        title: data.driver_name+'的银行卡信息',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['100%', '100%'],
                        content: '{:url("/admin/driver/driverBank","driver_id=")}' + driver_id //iframe的url
                    });
                }
            });
        });
    </script>
</block>
